package com.power.web;

import com.github.pagehelper.PageInfo;
import com.power.model.TClueRemark;
import com.power.query.ClueRemarkQuery;
import com.power.result.R;
import com.power.service.ClueRemarkService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class ClueRemarkController {
    @Resource
    private ClueRemarkService clueRemarkService;

    @PostMapping("/api/clue/remark")
    public R addClueRemark(@RequestBody ClueRemarkQuery clueRemarkQuery, @RequestHeader("token") String token) {
        clueRemarkQuery.setToken(token);
        int saveCount = clueRemarkService.saveClueRemark(clueRemarkQuery);
        return saveCount >= 1 ? R.OK() : R.FAIL();
    }

    @GetMapping("/api/clue/remark")
    public R getClueRemarkByPage(@RequestParam(value = "currentPage", required = false, defaultValue = "1") Integer currentPage,
                                 @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize,
                                 @RequestParam(value = "clueId") Integer clueId) {
        ClueRemarkQuery clueRemarkQuery = new ClueRemarkQuery();
        clueRemarkQuery.setClueId(clueId);
        PageInfo<TClueRemark> pageInfo = clueRemarkService.selectClueRemarkByPage(currentPage, pageSize, clueRemarkQuery);
        return R.OK(pageInfo);
    }
}
